﻿using AutoMapper;
using BPMN.Application.Contracts.DTO.Request.Dictionary;
using BPMN.Application.Contracts.DTO.Response.Dictionary;
using BPMN.Application.Contracts.DTO.Response;
using BPMN.Application.IService;
using BPMN.Domain.Entity.SysDictonary;
using BPMN.Domain.Interface;
using BPMN.DomianShare;
using BPMN.DomianShare.PulicDto;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.Design;
using System.Security.Cryptography;

namespace BPMN.WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DitonaryController : ControllerBase
    {
        /// <summary>
        /// 全局变量
        /// </summary>
        private readonly IDitonaryAppService AppDit;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="AppDit"></param>
        public DitonaryController(IDitonaryAppService AppDit)
        {
            this.AppDit = AppDit;
        }

        /// <summary>
        /// 字典信息添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> AddDitonary(DictionaryRequstDto entity)
        {
            return Ok(await AppDit.AddDitonary(entity));
        }

        /// <summary>
        ///添加字典明细（返回字典集合）
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> AddDitonaryList(DictionaryListrequestDto entity)
        {
            return Ok(await AppDit.AddDitonaryList(entity));
        }
        /// <summary>
        /// 获取数据字典列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetDictonary()
        {
            return Ok(await AppDit.GetDictonaryList());
        }

        /// <summary>
        /// 获取字典明细信息
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetDictionaryListMx(int Id)
        {
            return Ok(await AppDit.GetDictionaryListMx(Id));
        }


        /// <summary>
        /// 根据字典ID获取相对用的数据
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetDicListByDicId(int Id)
        {
            return Ok(await AppDit.GetDicListByDicId(Id));
        }


    }
}
